import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';

const routes: Array<RouteRecordRaw> = [
  // {
  //     path: '/',
  //     name: 'Login',
  //     // 异步加载，打包时代码分割，性能优化
  //     component: () => import('../components/login.vue') 
  // },
  {
    path: '/login',
    name: 'index',
    meta: {
      title: 'home',
    },
    component: () => import('@/views/login/index.vue'),
  },
  {
    path: '/standstep',
    name: 'standstep',
    meta: {
      title: '标准工序库',
    },
    component: () => import('@/views/doc/stand/index.vue'),
  },
  {
    path: '/basedata',
    name: 'basedata',
    meta: {
      title: '基础数据维护',
    },
    component: () => import('@/views/doc/base/index.vue'),
  },
  {
    path: '/technology',
    name: 'technology',
    meta: {
      title: '工艺文件管理',
    },
    component: () => import('@/views/doc/technology/index.vue'),
  },
  {
    path: '/',
    name: 'generate',
    meta: {
      title: '智能生成',
    },
    component: () => import('@/views/generate/index.vue'),
  },
  {
    path: '/result',
    name: 'result',
    component: () => import('@/views/generate/result/index.vue')
  },
  {
    path: '/doc',
    name: 'doc',
    meta: {
      title: '文档库',
    },
    component: () => import('@/views/doc/index.vue'),
  },
]
// routes.push(...route);
//导入生成的路由数据
const router = createRouter({
  history: createWebHistory(),
  routes: routes
});

router.beforeEach(async (_to, _from, next) => {
  NProgress.start();
  next();
});

router.afterEach((_to) => {
  NProgress.done();
});

export default router;
